<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<base href="<%=basePath%>">

<div class="row-fluid" id='newsRe'>
   <c:if test="${delFile==true }">
   <div class="ts" style='height:40px;padding:1px;width:90%;'>
	  <div style='margin-top:15px;'><p align="center" style='color:'>删除成功</p></div>
	</div>
</c:if>
<c:if test="${delFile==false }">
   <div class="ts" style='height:40px;padding:1px;width:90%;'>
	  <div style='margin-top:15px;'><p align="center" style='color:'>删除失败</p></div>
	</div>
</c:if>
<c:if test="${not empty allnews }">
      <div class='' id='news' style='padding:0px;'>
         <div style='-webkit-border-radius:10px;' class='right border1'>
            <table class="table table-hover" style="width: 100%;margin-top:10px;">
            <tbody>
			<c:forEach items="${allnews }" var="news">
			
			<tr>
			<td ><img src="<%=basePath %>images/li1.gif" style='margin-right:5px;'/><a class='downloadA' href="<c:url  value='/backend/download' />" filename='${news.dataPath }' title='${news.dataName }'><p class='newsTitle1'>${news.dataName }</p></a></td>
			<td align="center" style='color:#990000;font-weight: bold;'>[${news.dataUploadTime }]</td>
			<td align="right"><i class=' icon-trash' ></i><button  class='deleteFile btn btn-info' dataid='${news.dataId}' href="<%=basePath%>backend/delFile" >删除</button></td>
			</tr>
			
			</c:forEach>
			</tbody>
			</table>
		<div id="" class="span12" style='margin-left:40%;margin-top:10px;'>
		   
	   <p> <a href='<%=basePath%>backend/ZiliaoManeger/1 '>首页</a>
	   <a href='<%=basePath%>backend/ZiliaoManeger/${pageNow-1 } ' id="first">[上一页]</a>
	   <a  class="pagenow">
	   <strong style='color:red;font-size:16px;'>${pageNow}</strong></a>...
	   <a href='<%=basePath%>backend/ZiliaoManeger/${pageCount }'>${pageCount }</a>
	   <a href='<%=basePath%>backend/ZiliaoManeger/${pageNow+1 } ' id="next">[下一页]</a>
	   <a href='<%=basePath%>backend/ZiliaoManeger/${pageCount } '>末页</a>
	   </p>
	</div>
         </div>
         
	<script type="text/javascript">
	   $(function(){
		   var page = ${pageNow};
		   var pageCount = ${pageCount};
		   if(parseFloat(page)+1 >parseFloat(pageCount))
			   {
			       $("#next").hide();
			   }
		   if(parseFloat(page)-1 <1)
			   {
			     $("#first").hide();
			   }else{
				   $("#first").show();
			   };
			   
			  
	   });
	</script>
      </div>
      </c:if>
      <c:if test="${empty allnews }">
         <h3 style="color:red">暂没文件被上传，请上传。</h3>
      </c:if>
    </div>
<script type="text/javascript">  
        $(function(){  
        	$(".downloadA").each(function(){
        		 $(this).click(function(){  
                     var link=this.href+'?'+'filename='+$(this).attr("filename");  
                     window.open(link);  
                     return false;  
                 }); 
        	});
        	$(".deleteFile").each(function(){
				 $(this).click(function(){
					
					 var uri = $(this).attr("href");
				     var id=$(this).attr("dataid");
					  alert(uri);
					 Boxy.confirm("<img src='../images/tixing.png' />确认删除！", function() { 
						// var uri = basePath + "backend/deletenbs" ;
						 $.ajax({   
							  type: "POST",  
							  url: uri,  
							  data: 'id=' + id,  
							  timeout: 15*1000,
							  success: function(data){ 
								 // alert(data);
								  if(data=="success")
								  { alert("删除成功！");
								    window.location.href = $("base").val() + "backend/ZiliaoManeger/1" ;
								  }								  
							  },
							  error:function(result){
					              	alert("出现异常！请稍后再试！");
					              }
						  });
					 }, {title: "提示信息"});	 
				 });
			}); 
        	
        });  
    </script> 
